//
//  BlendMode.m
//  QuartzStudy
//
//  Created by longhuihu on 11-6-21.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "BlendShape.h"

static CGFloat hong[]= {1,0,0,1};//FF0000 
static CGFloat cheng[]={1,0.498,0,1} ;//#FF7F00
static CGFloat huang[]={1,1,0,1};//#FFFF00 
static CGFloat liu[]={0,1,0,1};//#00FF00 
static CGFloat qing[]={0,1,1,1};//#00FFFF 
static CGFloat lan[]={0,0,1,1};//#0000FF
static CGFloat zi[]={0.545,0,1,1};//#8B00FF
static CGFloat* colors[]= {hong,cheng,huang,liu,qing,lan,zi};

@implementation BlendShape

@synthesize blendMode;

- (void)drawRect:(CGRect)rect
{
	CGContextRef context = UIGraphicsGetCurrentContext();
	CGContextClearRect(context, self.bounds);
	CGContextSetBlendMode(context,self.blendMode);
	CGFloat x1 = 50;
	CGFloat y1 = 0;
	CGFloat height = self.bounds.size.height;
	CGFloat step = 15;
	
	for (int i=0; i<7; i++) {
		CGContextSetFillColor(context, colors[i]);
		CGContextFillRect(context, CGRectMake(x1+step*i, y1, step, height));
	}
	

	CGFloat x2 = 0;
	CGFloat y2 = self.bounds.size.height - step;
	CGFloat width = self.bounds.size.width;
	
	for (int i=0; i<7; i++) {
		CGContextSetFillColor(context, colors[i]);
		CGContextFillRect(context, CGRectMake(x2, y2-step*i,width,step));
	}
}

@end
